import {
    debounce,
    on
} from './util'
import CursorEffects from './CursorEffects'


export default ({
    Vue
}) => {
  // 点击特效
  let cursorEffects = new CursorEffects()
  cursorEffects.init()
  on(window, 'resize', debounce(function() {
    cursorEffects.destroy()
    cursorEffects = new CursorEffects()
    cursorEffects.init()
  }, 300))

   // title 变化
   let title = 'PengPeng'
   let titleTime
   const comeback = '′▽`，我胡汉三又回来了'
   on(document, 'visibilitychange', function() {
     if (document.hidden) {
       document.querySelector('link[rel="icon"]').href = '/yanglele_blogs/sad.ico'
       if (document.title !== comeback) title = document.title
       document.title = '宝宝心里苦，但我不说'
       clearTimeout(titleTime)
     } else {
       document.querySelector('link[rel="icon"]').href = '/yanglele_blogs/favicon.ico'
       document.title = comeback
       titleTime = setTimeout(function() {
         document.title = title
       }, 1000)
     }
   })
}